<?php

class RSSItem extends Base {

  /** @var String The title. */
  private $title = "";

  /** @var String The link. */
  private $link = "";

  /** @var String The description. */
  private $description = "";

  /** @var DateTimeParser The publication date. */
  private $publication_date = "";

  /** @var String The author. */
  private $author = "";

  /** @var String The category. */
  private $category = "";

  /** @var String The comments. */
  private $comments = "";

  /** @var String The enclosure. */
  private $enclosure = "";

  /** @var String The unique identifier. */
  private $guid = "";

  /** @var String The third party source. */
  private $source = "";

  /**
   * Creates a RSS item with mandatory child tags.
   * @param String $title The title.
   * @param String $link The link.
   * @param String $description The description.
   * @param DateTimeParser $publication_date The publication date.
   */
  function __construct(IString $title, IString $link, IString $description, DateTimeParser $publication_date) {
    $this->title = $title;
    $this->link = $link;
    $this->description = $description;
    $this->publication_date = $publication_date;
  }

  /**
   * Returns the title.
   * @return String The title.
   */
  public function getTitle() {
    return $this->title;
  }

  /**
   * Returns the link.
   * @return String The link.
   */
  public function getLink() {
    return $this->link;
  }

  /**
   * Returns the description.
   * @return String The description.
   */
  public function getDescription() {
    return $this->description;
  }

  /**
   * Returns the publication date.
   * @return DateTimeParser The publication date.
   */
  public function getPublicationDate() {
    return $this->publication_date;
  }

  /**
   * Returns the author.
   * @return String The author
   */
  public function getAuthor() {
    return $this->author;
  }

  /**
   * Sets the author.
   * @param String $author The author.
   */
  public function setAuthor(IString $author) {
    $this->author = $author;
  }

  /**
   * Returns the category.
   * @return String The category.
   */
  public function getCategory() {
    return $this->category;
  }

  /**
   * Sets the category.
   * @param String $category The category.
   */
  public function setCategory(IString $category) {
    $this->category = $category;
  }

  /**
   * Returns the comment.
   * @return String The comments.
   */
  public function getComments() {
    return $this->comments;
  }

  /**
   * Sets the comment.
   * @param String $comments The comments
   */
  public function setComments(IString $comments) {
    $this->comments = $comments;
  }

  /**
   * Returns the enclosure.
   * @return String The enclosure.
   */
  public function getEnclosure() {
    return $this->enclosure;
  }

  /**
   * Sets the enclosure.
   * @param String $enclosure
   */
  public function setEnclosure(IString $enclosure) {
    $this->enclosure = $enclosure;
  }

  /**
   * Returns the guid.
   * @return String The guid.
   */
  public function getGuid() {
    return $this->guid;
  }

  /**
   * Sets the guid.
   * @param IString $guid The guid.
   */
  public function setGuid(IString $guid) {
    $this->guid = $guid;
  }

  /**
   * Returns the source.
   * @return String The source.
   */
  public function getSource() {
    return $this->source;
  }

  /**
   * Sets the source.
   * @param String $source The source.
   */
  public function setSource(IString $source) {
    $this->source = $source;
  }

  /**
   * Return an XML item node.
   * @return string An XML node.
   */
  public function getItem() {
    $Item = "    <item>\r\n" .
            "      <title>" . $this->title->toString() . "</title>\r\n" .
            "      <link>" . $this->link->toString() . "</link>\r\n" .
            "      <description>" . $this->description->toString() . "</description>\r\n" .
            "      <pubDate>" . $this->publication_date->toShortDateString() . "</pubDate>\r\n";

    if (!$this->author->isEmpty()->booleanValue())
      $Item .= "      <author>" . $this->author->toString() . "</author>\r\n";

    if (!$this->category->isEmpty()->booleanValue())
      $Item .= "      <category>" . $this->category->toString() . "</category>\r\n";

    if (!$this->comments->isEmpty()->booleanValue())
      $Item .= "      <comments>" . $this->comments->toString() . "</comments>\r\n";

    if (!$this->enclosure->isEmpty()->booleanValue())
      $Item .= "      <enclosure>" . $this->enclosure->toString() . "</enclosure>\r\n";

    if (!$this->guid->isEmpty()->booleanValue())
      $Item .= "      <guid>" . $this->guid->toString() . "</guid>\r\n";

    if (!$this->source->isEmpty()->booleanValue())
      $Item .= "      <source>" . $this->source->toString() . "</source>\r\n";

    $Item .= "    </item>\r\n";

    return $Item;
  }

}

?>
